<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('市级未签收T')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="post-form">
                <div class="select-list">
                    <ul>
                        <li>
                            工单编号：<input type="text" name="myTwfNO"/>
                        </li>
                        <li>
                            派发单位：<input type="text" name="sbdeptName"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                            <a class="btn btn-info btn-rounded btn-sm" onclick="sameSearch()"><i
                                    class="fa fa-send"></i>&nbsp;同源派单</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm " id="toolbar" role="group">
            <a class="btn btn-success single disabled" onclick="signPage()">
                <i class="fa fa-plus"></i> 处理
            </a>
            <a class="btn btn-success multiple disabled" onclick="printX()">
                <i class="fa fa-print"></i> 转办单
            </a>
            <a class="btn btn-primary" onclick="belowSend()">
                 下派办理期限配置
            </a>
            <a class="btn btn-primary" onclick="autoDeferSet()" th:if="${session.ssnObjUser.loginName == 'px1' || session.ssnObjUser.loginName == 'jjq1'}">
                 下派自动延期配置
            </a>
            <a class="btn btn-primary" onclick="subSendGoBack()">
                下派退回配置
            </a>
<!--            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">-->
<!--                <i class="fa fa-remove"></i> 删除-->
<!--            </a>-->
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "gaoxin/system/mTelWF";
    var cmnTab = ctx + "gaoxin/system/cmnTab";

    function printX() {
        var url = prefix+"/forShow/printSends";
        let row = $("#bootstrap-table").bootstrapTable('getSelections');
        if (row.length < 2) {
            url += "?ids="+row[0].pkId;
        }else {
            var ids = '';
            for (let i = 0; i < row.length; i++) {
                ids += row[i].pkId;
                if ((i+1) != row.length) {
                    ids += ","
                }
            }
            url += "?ids="+ids;
        }
        window.open(url,"printX",'left=100,top=20,height=700,width=720,toolbar=yes,menubar=yes,scrollbars=auto');
    }

    function belowSend() {
        var url = '/system/deptdeadline/config';
        var title = '下派办理期限配置';
        var width = "500px";
        var height = "500px";
        var options = {
            url: url,
            title: title,
            width: width,
            height: height,
            btnArr: []
        }
        winDialog(options);
    }

    function autoDeferSet() {
        var url = '/system/deferAuto/config';
        var title = '下派自动延期配置';
        var width = "460px";
        var height = "310px";
        var options = {
            url: url,
            title: title,
            width: width,
            height: height,
            btnArr: []
        }
        winDialog(options);
    }


    $(function () {
        var options = {
            url: prefix + "/cmnFile/muSignNotJson",
            sortName: "pkId",
            sortOrder: "desc",
            uniqueId: "pkId",
            updateUrl: "/gaoxin/system/cmnTab/twfCSignS/{id}",
            removeUrl: "/gaoxin/system/sendBack/remove",
            modalName: "市级未签收T",
            fixedColumns: true,
            fixedNumber: 2,
            fixedRightNumber: 2,
            rowStyle: rowStyle,
            columns: [{
                checkbox: true
            },
                {field: 'pkId', title: 'pkid',visible:false},
                {field: 'wfId', title: 'wfId',visible:false},
                {field: 'myTwfNO', title: '工单编号', align: 'center', sortable: true},
                {field: 'myTwfTopic', title: '工单主题', align: 'center'},
                {field: 'fmContent', title: '工单内容', align: 'center',formatter:function (value, row, index,field) {
                        var obj = rowStyle(row)
                        if(obj == '')
                            return "<span style='cursor: pointer;' title='"+value+"'>"+value+"</span>"
                        if(obj.css.color == 'blue')
                            return "<span style='cursor: pointer;color: blue;font-weight: bold;' title='"+value+"'>"+value+"</span>"
                        else if(obj.css.color == 'red')
                            return "<span style='cursor: pointer;color: red;font-weight: bold;' title='"+value+"'>"+value+"</span>"
                    },
                    cellStyle: cellEllipsis},
                {field: 'seqName', title: '交办次序', align: 'center'},
                {field: 'sortName', title: '性质', align: 'center'},
                {field: 'dealName', title: '办理方式', align: 'center'},
                {field: 'bkLimit', title: '办理期限', align: 'center', sortable: true},
                {field: 'sdeptName', title: '来自', align: 'center'},
                // {
                //     field: 'sattachPath',
                //     title: '直派',
                //     align: 'center',
                // },
                {field: 'sdDate', title: '派发日期', align: 'center', sortable: true, width: '100px'},
                {field: 'sendRemark', title: '备注', align: 'center', halign: 'center',formatter:function (value, row, index,field) {
                        var obj = rowStyle(row)
                        if(obj == '')
                            return "<span style='cursor: pointer;' title='"+value+"'>"+value+"</span>"
                        if(obj.css.color == 'blue')
                            return "<span style='cursor: pointer;color: blue;font-weight: bold;' title='"+value+"'>"+value+"</span>"
                        else if(obj.css.color == 'red')
                            return "<span style='cursor: pointer;color: red;font-weight: bold;' title='"+value+"'>"+value+"</span>"
                    },
                    cellStyle: cellEllipsis},
                {
                    field: 'mark',
                    title: '是否紧急',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var mark = row.mark;
                        var rtn = "否"
                        if (mark == 1) {
                            rtn = "<span style='color:red;'>是</span>"
                        }
                        return rtn;
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    events: "operateEvents",
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="signPage(\'' + row.pkId + '\',\'电话工单签收处理\')"><i class="fa fa-edit"></i>处理</a> ');
                        actions.push('<a id="id_row_tosend" class="btn btn-success btn-xs" href="javascript:void(0)"><i class="fa fa-edit"></i>转派</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    window.operateEvents = {
        "click #id_row_tosend": function (e, value, row, index) {
            var wfId = row.wfId;
            var sbId = row.pkId;
            transferSendToSon(wfId,sbId);
        }
    }

    //处理
    function signPage(id,title) {
        table.set();
        $.modal.openTab("处理" + table.options.modalName, $.operate.editUrl(id));
    }

    //转派
    function transferSendToSon(wfId,sbId) {
        var url = cmnTab + "/twfCSendWaitZP/"+sbId+"?wfId="+wfId;
        var width = '85%';
        var height = '95%';
        var config = {
            id: 'dlSendToSon',
            title: '拟办部门',
            width: width,
            height: height,
            url: url,
            yes: function (index, layero){
                var iframeWin = layero.find('iframe')[0];
                beforeSend();
                debugger
                iframeWin.contentWindow.document.getElementById('navFrame').contentWindow.submitHandler(index);
                completeSend();
            }
        };
        $.modal.openOptions(config);
    }

    function sameSearch(){
        var btn = ['<i class="fa fa-check"></i> 同源派单', '<i class="fa fa-close"></i> 取消派单'];
        var options = {
            width: '75%',
            height: '90%',
            title: '同源派单',
            url: prefix + "/cmnFile/searchForm",
            btn: btn,
            callBack: function (index, layero){
                var iframeWin = layero.find('iframe')[0];
                iframeWin.contentWindow.submitHandler();
            }
        };
        $.modal.openOptions(options);
    }

    //下派退回配置
    function subSendGoBack(){
        var options = {
            id: 'subSendGoBack',
            title: '下派退回配置',
            width: '40%',
            height: '60%',
            url: prefix + '/rManage/goBackConfig',
            callBack: function (index, layero){
                var iframeWin = layero.find('iframe')[0];
                iframeWin.contentWindow.submitHandler();
            }
        }
        $.modal.openOptions(options);
    }
</script>
</body>
</html>